$(document).ready(function() {
// This runs the dosomething function every 500ms 
redrawvlc();
var timeoutID = window.setInterval(vlcWatcher, 500);	

//Adjusting layout of page 
$("#timeslider").progressbar({ maxValue: 1000, stepping: 1});
$('#timeslider').css({'width': '640px'});
$('#timeslider').css({ 'position': 'absolute', 'top': '365px', 'left': '0px','height': '10px'});
$('#volumeslider').slider({ orientation: 'vertical', max: 200, min: 0, animate: true });
$('#volumeslider').css({ 'height': '350px', 'width': '10px', 'position': 'absolute', 'top': '0px', 'left': '648px' });
$('#volumeslider').slider({ change: function() { 
				vlc.audio.volume = parseInt($('#volumeslider').slider('option', 'value')); 
			   }	
			 });


$('#playerwindow').css({'background-color': '#000000', 'width': '640px', 'height': '360px', 'position': 'absolute', 'top': '0px', 'left': '0px'});
$('#nexttovid').css({ 'position': 'absolute', 'top': '0px', 'right': '0px', 'background-color': '#dddddd', 'width': '500', 'height': '100%'}); 


function vlcWatcher() {
var vlc = document.getElementById("vlc");

	if(vlc.input.state == 6) {
		  redrawvlc(); 
	}

  	//$('#debug p').html(vlc.input.state + " " + Math.round(vlc.input.time/100) + " " + Math.round(vlc.input.length/100));
	var currenttime = Math.round((vlc.input.time/vlc.input.length)*100);
	$("#timeslider").progressbar('value', currenttime);

}


});


function redrawvlc(id) {
	$('#playerwindow span').load('./vlc.php?id=651');

}

